package org.java8newfeature.stream;

import java.util.Arrays;
import java.util.Comparator;
import java.util.List;

public class StreamSorted {
    public static void main(String[] args) {
       /* List<String> cities = Arrays.asList("Milan", "london", "San Francisco", "Tokyo", "New Delhi");
        cities.sort(String.CASE_INSENSITIVE_ORDER);
        System.out.println(cities);

        cities.sort(Comparator.naturalOrder());
        System.out.println(cities);

        cities.stream().sorted(Comparator.naturalOrder()).forEach(System.out::println);*/

        Employee e1 = new Employee(1, 23, "M", "Rick", "Beethovan");
        Employee e2 = new Employee(2, 13, "F", "Martina", "Hengis");
        Employee e3 = new Employee(3, 43, "M", "Ricky", "Martin");
        Employee e4 = new Employee(4, 26, "M", "Jon", "Lowman");
        Employee e5 = new Employee(5, 19, "F", "Cristine", "Maria");
        Employee e6 = new Employee(6, 15, "M", "David", "Feezor");
        Employee e7 = new Employee(7, 68, "F", "Melissa", "Roy");
        Employee e8 = new Employee(8, 79, "M", "Alex", "Gussin");
        Employee e9 = new Employee(9, 15, "F", "Neetu", "Singh");
        Employee e10 = new Employee(10, 45, "M", "Naveen", "Jain");
/*
        List<Employee> employees = Arrays.asList(e1, e2, e3, e4, e5, e6, e7, e8, e9, e10);

        employees.sort(Comparator.comparing(Employee::getAge));
        employees.forEach(System.out::println);

        List<Employee> employees2 = Arrays.asList(e1, e2, e3, e4, e5, e6, e7, e8, e9, e10);
        employees2.sort(Comparator.comparing(Employee::getAge).reversed());
        employees2.forEach(System.out::println);*/

        List<Employee> employees3 = Arrays.asList(e1, e2, e3, e4, e5, e6, e7, e8, e9, e10);

        employees3.sort(
                Comparator.comparing(Employee::getGender)
                        .reversed()
                        .thenComparing(Employee::getAge)
                        .reversed()
        );
        employees3.forEach(System.out::println);


        employees3.stream().filter(Employee.ageGreaterThan70).sorted(Comparator.comparing(Employee::getAge));
    }
}
